// 云函数入口文件
const cloud = require('wx-server-sdk')
const fs = require('fs')
const path = require('path')

cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }) // 使用当前云环境

// 云函数入口函数
exports.main = async (event, context) => {
    let arr = event.fileList.map(item => {
        const fileStream = fs.createReadStream(item.url)
        return cloud.uploadFile({
            cloudPath: new Date().getTime() + Math.random() + ".png",
            fileContent: fileStream
        })
    })
    console.log(arr, "$$$")
    return;
    let result = await Promise.all(arr).catch(err => console.error(err))
}